package com.ly.web.controller.erp;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.SaleMakedDetailEntity;
import com.ly.heart.service.ISaleMakedDetailService;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 销售价目详情Controller
 * 
 * @author wutao
 * @date 2024-07-15
 */
@Api(value = "markedDetail", tags = "销售价目详情")
@RestController
@RequestMapping("/heart/markedDetail")
public class SaleMakedDetailController extends BaseController {

    @Resource
    private ISaleMakedDetailService saleMakedDetailService;

    /**
     * 查询销售价目详情列表
     */
    @PreAuthorize("@ss.hasPermi('heart:markedDetail:list')")
    @GetMapping("/list")
    @ApiOperation("查询销售价目详情列表")
    public TableDataInfo list(SaleMakedDetailEntity saleMakedDetail)
    {
        startPage();
        List<SaleMakedDetailEntity> list = saleMakedDetailService.selectSaleMakedDetailList(saleMakedDetail);
        return getDataTable(list);
    }

    /**
     * 导出销售价目详情列表
     */
    @PreAuthorize("@ss.hasPermi('heart:markedDetail:export')")
    @Log(title = "销售价目详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出销售价目详情列表")
    public AjaxResult export(SaleMakedDetailEntity saleMakedDetail)
    {
        List<SaleMakedDetailEntity> list = saleMakedDetailService.selectSaleMakedDetailList(saleMakedDetail);
        ExcelUtil<SaleMakedDetailEntity> util = new ExcelUtil<SaleMakedDetailEntity>(SaleMakedDetailEntity.class);
        return util.exportExcel(list, "markedDetail");
    }

    /**
     * 获取销售价目详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('heart:markedDetail:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取销售价目详情详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(saleMakedDetailService.selectSaleMakedDetailById(id));
    }

    /**
     * 新增销售价目详情
     */
    @PreAuthorize("@ss.hasPermi('heart:markedDetail:add')")
    @Log(title = "销售价目详情", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增销售价目详情")
    public AjaxResult add(@RequestBody SaleMakedDetailEntity saleMakedDetail)
    {
        return toAjax(saleMakedDetailService.insertSaleMakedDetail(saleMakedDetail));
    }

    /**
     * 修改销售价目详情
     */
    @PreAuthorize("@ss.hasPermi('heart:markedDetail:edit')")
    @Log(title = "销售价目详情", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改销售价目详情")
    public AjaxResult edit(@RequestBody SaleMakedDetailEntity saleMakedDetail)
    {
        return toAjax(saleMakedDetailService.updateSaleMakedDetail(saleMakedDetail));
    }

    /**
     * 删除销售价目详情
     */
    @PreAuthorize("@ss.hasPermi('heart:markedDetail:remove')")
    @Log(title = "销售价目详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除销售价目详情")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(saleMakedDetailService.deleteSaleMakedDetailByIds(ids));
    }
}
